package com.mowh.multithreading.read.write.lock;

/**
 * @author mowh1gd
 * @create 2023/11/21 17:15
 */
public class ReaderThread extends Thread {//扮演Reader
    private final Data data;

    public ReaderThread(Data data) {
        this.data = data;
    }

    @Override
    public void run() {
        try {
            while (true) {
                char[] readBuf = data.read();
                System.out.println(Thread.currentThread().getName() + " reads " + String.valueOf(readBuf));
            }
        } catch (InterruptedException e) {
        }
    }
}
